

export default {
    data() {
        return {
          show:true,
      }  
    },
    computed: {
        detail() {
            return this.$store.state.firstNameDetail;
        }
    },
    template: `
    <div>
        <p v-if="show">加载中...</p>
        <div v-html="detail"></div>
    </div>
    `,

    created() {
        console.log(this.$route.query.xing);
        let xing = this.$route.query.xing;
        if (xing) {
            this.getDetail(xing);
        }
    },
    methods: {
        getDetail(firstName) {
            console.log(firstName);
            let that = this;
            axios.get('http://api.tianapi.com/txapi/surname/index', {
                params: {
                    key: 'e5df028fd20892f8103f9724e6dd85cf',
                    xing:  firstName
                }
            }).then((response) => {
                that.show = false;
                that.$store.commit("add", response.data.newslist[0].content);
                console.log(response.data.newslist[0].content);
            }).catch((error) => {
                console.log(error);
            })
        }
    },
}